<script  setup>
import {defineProps, ref} from "vue";
import { ArrowDown } from '@element-plus/icons-vue'
const  props = defineProps({
  dropdownList: {
    type: Array,
    default: () => []
  },
  dropdownTitle: {
    type: String,
    default: '请选择'
  },
  updataDropdown: {
    type: Function,
    default: () => {}
  }
})
const  dropdownList =ref(props.dropdownList)
const  dropdownTitle =ref(props.dropdownTitle)
const  updataDropdown =ref(props.updataDropdown)
const handleClick = (e) => {
  updataDropdown.value(e)
  dropdownTitle.value = e.name
}
</script>

<template>
  <el-dropdown @command="handleClick">
    <span class="el-dropdown-link">
     {{ dropdownTitle}}
      <el-icon class="el-icon--right">
        <arrow-down />
      </el-icon>
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item v-for="(item,i) in dropdownList " :key="i" :command="item">{{item.name}}</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<style scoped lang="scss">
.el-dropdown-link{
  background-image: url("./背景.png");
  background-repeat: no-repeat;
  //background-position:;
  background-size: 100% 100%;
   min-width: 82.42px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: #ffff;
  cursor: pointer;
  outline: none;
}
</style>
